package cn.lg.soar.system.general.model;

import cn.lg.soar.system.general.entity.DictItem;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
public class DictItemVo {

    @ApiModelProperty(value = "字典值")
    private Integer value;

    @ApiModelProperty(value = "字典标签")
    private String label;

    @ApiModelProperty(value = "元数据（可配置其他参数）")
    private String metadata;

    @ApiModelProperty(value = "是否禁用")
    private Boolean disabled;

    public DictItemVo(){}

    public DictItemVo(Integer value, String label){
        this.value = value;
        this.label = label;
    }

    public DictItemVo(DictItem data) {
        if (data == null) {
            return;
        }
        this.value = data.getValue();
        this.label = data.getLabel();
        this.metadata = data.getMetadata();
        this.disabled = data.getDisabled();
    }

    public DictItem toDictItem() {
        DictItem dictItem = new DictItem();
        dictItem.setValue(this.value);
        dictItem.setLabel(this.label);
        dictItem.setMetadata(this.metadata);
        dictItem.setDisabled(this.disabled);
        return dictItem;
    }
}
